package cn.kgc.tangcco.kjde1020.mall.controller;

import cn.kgc.tangcco.kjde1020.mall.service.IProductService;
import cn.kgc.tangcco.kjde1020.mall.vo.ProductDetailVo;
import cn.kgc.tangcco.kjde1020.mall.vo.ResponseVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ProductController
 * @Description: TODO
 * @Author 郭建宾
 * @Date 2020/3/2
 * @Version V1.0
 **/
@RestController
public class ProductController {
    @Autowired
    private IProductService productService;
    @GetMapping("/products")
    public ResponseVo<PageInfo> list(@RequestParam(required = false)Integer categoryId,
                                     @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                     @RequestParam(required = false, defaultValue = "10") Integer pageSize) {

        return  productService.list(categoryId,pageNum,pageSize);
    }
    @GetMapping("/products/{productId}")
    public  ResponseVo<ProductDetailVo> detail(@PathVariable Integer productId){
        return  productService.detail(productId);
    }
}
